home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / games / worm.zip / BIBLIO.C < prev    next >
C/C++ Source or Header  |  1992-09-21  |  2KB  |  74 lines

  1.  
  2. #include "worm.h"
  3.  
  4. /* ------------------------------------------------------------------ */
  5.  
  6. int ErrorBox(char *message)
  7. {
  8.  return (MessageBox ( GetFocus(), message,
  9.               "Worming Error", MB_ICONASTERISK | MB_OK));
  10. }
  11.  
  12. /* ------------------------------------------------------------------ */
  13.  
  14. void CreateDialogBox(HWND hWnd, FARPROC DlgProc, int idd)
  15. {
  16.    extern HANDLE hInst;
  17.    FARPROC lpProc;
  18.  
  19.    lpProc = MakeProcInstance(DlgProc, hInst);
  20.    DialogBox(hInst, MAKEINTRESOURCE(idd), hWnd, lpProc);
  21.    FreeProcInstance(lpProc);
  22. }
  23. /* ------------------------------------------------------------------ */
  24. /* The following pseudo-random sequence generator was published in
  25.    Dr. Dobb's Journal, February 1992. I beleive it to be superior to the
  26.    rand function.
  27. */
  28. unsigned LSFR(void)
  29. {
  30.  static unsigned long reg = 10;
  31.  
  32.  reg = ((((reg >> 31) /* shift the 32nd bit to the first bit */
  33.       ^ (reg >> 6)   /* XOR it with the seventh bit */
  34.       ^ (reg >> 4)   /* XOR it with the fifth bit   */
  35.       ^ (reg >> 2)   /* XOR it with the third bit   */
  36.       ^ (reg >> 1)   /* XOR it with the second bit  */
  37.       ^ reg)         /* XOR it with the fist bit    */
  38.        & 0x00000001)  /* strip all the other bits off and */
  39.       << 31)         /* move it back to the 32nd bit.    */
  40.       | (reg >> 1);  /* or it with the register shifted right. */
  41.  
  42.  return (int) reg & 0x00000001; /* return the first bit */
  43.  
  44. }
  45. /* ------------------------------------------------------------ */
  46. BOOL IsOnDesktop(POINT testPoint)
  47. {
  48.   HWND desktopHandle = GetDesktopWindow();
  49.   POINT point;
  50.   int size = GetSize();
  51.  
  52.   point.x = testPoint.x + size;
  53.   point.y = testPoint.y + size;
  54.   if(WindowFromPoint(point) != desktopHandle)
  55.      return FALSE;
  56.  
  57.   point.x = testPoint.x - size;
  58.   if(WindowFromPoint(point) != desktopHandle)
  59.      return FALSE;
  60.  
  61.   point.y = testPoint.y - size;
  62.   if(WindowFromPoint(point) != desktopHandle)
  63.      return FALSE;
  64.  
  65.   point.x = testPoint.x + size;
  66.   if(WindowFromPoint(point) != desktopHandle)
  67.      return FALSE;
  68.  
  69.   return TRUE;
  70. }
  71.  
  72. /* ------------------------------------------------------------------ */
  73.  
  74. /* EOF */